<template>
	<view v-if="pageShow">
		<view class="mainpadding2 ffffff">
			<u-tabs :list="tabslist" :scrollable="false"  lineColor="#3478f5" @click="changetab"
				:activeStyle="{
		    color: '#3478f5',
		    fontWeight: 'bold',
		    transform: 'scale(1.05)'
		}" :inactiveStyle="{
		            color: '#333333',
					fontWeight: '540',
		            transform: 'scale(1)'
		        }" itemStyle="padding-left: 10px; padding-right: 10px; height: 44px;"></u-tabs>
		</view>
		<view class="mainpadding2">
			<view class="flexcenter" v-if="!list.data.length">
				<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
			</view>
			<view class="mainpadding ffffff radius margin_top" v-for="item in list.data" :key="item.id" @click="jumpdetail(item.id)">
				<view class="flexbetween">
					<view class="bigtext fonweight xiaohei">{{item.order_on}}</view>
					<view class="xiaohong sanshier fonweight" v-if="item.pay_status==1">待付款</view>
					<view class="xiaolan sanshier fonweight" v-if="item.pay_status==2"> 已付款</view>
					<view class="xiaohuang sanshier fonweight" v-if="item.pay_status==3"> 待转拍</view>
					<view class="xiaolv sanshier fonweight" v-if="item.pay_status==4"> 已完成</view>
					<view class="xiaohui sanshier fonweight" v-if="item.pay_status==5"> 已取消</view>
				</view>
				<view class="margin_top2 flexbetween">
					<view class="shilitu">
						<image :src="item.goods_image_text" mode=""></image>
					</view>
					<view class="flexcolumnbet" style="width: 66%;height: 180rpx;">
						<view class="xiaohei titletext fonweight xiankuan">{{item.goods_name}}</view>
						<view class="xiaohui titletext nofonweight">积分抵扣：{{item.score}}</view>
						<view class="xiaohui titletext nofonweight">实付金额：
							<text class="xiaohong titletext fonweight">{{item.pay_price}}</text>
						</view>
						<view class="flexbetween" style="width: 100%">
							<view class="xiaohui titletext nofonweight margin_top1">*1</view>
							<view class="xiaohei titletext nofonweight margin_top1">总价：
								<text class="xiaohong titletext fonweight">{{item.price}}</text>
							</view>
						</view>
					</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="xiaohei titletext nofonweight">{{item.createtime_text}}</view>
					<view class="listbtn xiaolan" v-if="item.pay_status==1" @click.stop="surepay(item.id)">确认付款</view>
					<view class="listbtn xiaolan" v-if="item.pay_status==3" @click.stop="zhuanpai(item.id)">点击转拍</view>
					<view class="listbtn xiaolan" v-if="item.pay_status!=3 && item.pay_status!=1">查看详情</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				tabsid: 0,
				tabslist: [{
						name: '全部',
						value: 0,
					},{
						name: '待付款',
						value: 1,
					},{
						name: '已付款',
						value: 2,
					}, {
						name: '待转拍',
						value: 3,
					}, {
						name: '已完成',
						value: 4,
					}
				],
				pageShow:false,
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			zhuanpai(id){
				uni.navigateTo({
					url:"/pages/dingdan/zhuanpaisure?id="+id
				})
			},
			jumpdetail(id){
				uni.navigateTo({
					url:"/pages/dingdan/maidanxq?id="+id
				})
			},
			surepay(id){
				uni.navigateTo({
					url:"/pages/dingdan/surepay?id="+id
				})
			},
			init(isPage, page) { //提现记录
				let _this = this
				let url = "/api/cccl/myBuyOrder"
				let data = {
					page: page || 1,
					limit: _this.limit,
					pay_status: this.tabsid
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
							this.pageShow = true
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			changetab(e) {
				this.tabsid = e.value
				this.init()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.shilitu {
		width: 190rpx;
		height: 180rpx;
		border-radius: 20rpx;

		image {
			border-radius: 20rpx;
			width: 100%;
			height: 100%;
		}
	}
</style>